/*
* coder: Dzlua
* email: 505544956@qq.com
* time : 2018-04-17 10:35
*/

#include "ui/ui.hpp"
#include <tchar.h>

#include <typeinfo>
#include <iostream>
using std::cout;
using std::wcout;
using std::endl;

template <typename T>
void show(const T& d) {
    cout << typeid(d).name() << "->" << d << endl;
}

template <typename T>
void wshow(const T& d) {
    wcout << typeid(d).name() << L"->" << d << endl;
}

#if defined(_UNICODE) || defined(UNICODE)
    #define tshow wshow
#else
    #define tshow show
#endif

void anyTOstr() {
    show(ui::any2str<char>(123));
    show(ui::any2str<short>(123));
    show(ui::any2str<int>(123));
    show(ui::any2str<long>(123));
    show(ui::any2str<uint8_t>(123));
    show(ui::any2str<uint16_t>(123));
    show(ui::any2str<uint32_t>(123));
    show(ui::any2str<uint64_t>(123));
    show(ui::any2str<ui::string>("123"));
    show(ui::any2str<ui::wstring>(L"123"));
    show(ui::any2str<ui::tstring>(_T("123")));
}

void strTOany() {
    ui::string str = "123";
    show(ui::str2any<char>(str));
    show(ui::str2any<short>(str));
    show(ui::str2any<int>(str));
    show(ui::str2any<long>(str));
    show(ui::str2any<uint8_t>(str));
    show(ui::str2any<uint16_t>(str));
    show(ui::str2any<uint32_t>(str));
    show(ui::str2any<uint64_t>(str));
    show(ui::str2any<ui::string>(str));
    wshow(ui::str2any<ui::wstring>(str));
    tshow(ui::str2any<ui::tstring>(str));
}

void anyTOwstr() {
    wshow(ui::any2wstr<char>(123));
    wshow(ui::any2wstr<short>(123));
    wshow(ui::any2wstr<int>(123));
    wshow(ui::any2wstr<long>(123));
    wshow(ui::any2wstr<uint8_t>(123));
    wshow(ui::any2wstr<uint16_t>(123));
    wshow(ui::any2wstr<uint32_t>(123));
    wshow(ui::any2wstr<uint64_t>(123));
    wshow(ui::any2wstr<ui::string>("123"));
    wshow(ui::any2wstr<ui::wstring>(L"123"));
    wshow(ui::any2wstr<ui::tstring>(_T("123")));
}

void wstrTOany() {
    ui::wstring str = L"123";
    wshow(ui::wstr2any<wchar_t>(str));
    wshow(ui::wstr2any<char>(str));
    wshow(ui::wstr2any<short>(str));
    wshow(ui::wstr2any<int>(str));
    wshow(ui::wstr2any<long>(str));
    wshow(ui::wstr2any<uint8_t>(str));
    wshow(ui::wstr2any<uint16_t>(str));
    wshow(ui::wstr2any<uint32_t>(str));
    wshow(ui::wstr2any<uint64_t>(str));
    show(ui::wstr2any<ui::string>(str));
    wshow(ui::wstr2any<ui::wstring>(str));
    tshow(ui::wstr2any<ui::tstring>(str));
}

void anyTOtstr() {
    tshow(ui::any2tstr<TCHAR>(123));
    tshow(ui::any2tstr<short>(123));
    tshow(ui::any2tstr<int>(123));
    tshow(ui::any2tstr<long>(123));
    tshow(ui::any2tstr<uint8_t>(123));
    tshow(ui::any2tstr<uint16_t>(123));
    tshow(ui::any2tstr<uint32_t>(123));
    tshow(ui::any2tstr<uint64_t>(123));
    tshow(ui::any2tstr<ui::string>("123"));
    tshow(ui::any2tstr<ui::wstring>(L"123"));
    tshow(ui::any2tstr<ui::tstring>(_T("123")));
}

void tstrTOany() {
    ui::tstring str = _T("123");
    tshow(ui::tstr2any<TCHAR>(str));
    tshow(ui::tstr2any<short>(str));
    tshow(ui::tstr2any<int>(str));
    tshow(ui::tstr2any<long>(str));
    //tshow(ui::tstr2any<uint8_t>(str));
    tshow(ui::tstr2any<uint16_t>(str));
    tshow(ui::tstr2any<uint32_t>(str));
    tshow(ui::tstr2any<uint64_t>(str));
    show(ui::tstr2any<ui::string>(str));
    wshow(ui::tstr2any<ui::wstring>(str));
    tshow(ui::tstr2any<ui::tstring>(str));
}

int main(int argc, char** argv)
{
    // any to string
    cout << "----- any to string -----" << endl;
    anyTOstr();
    cout << "----- string to any -----" << endl;
    strTOany();
    cout << "----- any to wstring -----" << endl;
    anyTOwstr();
    cout << "----- wstring to any -----" << endl;
    wstrTOany();
    cout << "----- any to tstring -----" << endl;
    anyTOtstr();
    cout << "----- tstring to any -----" << endl;
    tstrTOany();
    return 0;
}